home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7700 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.6 KB  |  66 lines

  1. Newsgroups: comp.lang.c++
  2. Path: netcom.com!marnold
  3. From: marnold@netcom.com (Matt Arnold)
  4. Subject: Re: DLL's with classes in them
  5. Message-ID: <marnoldDnBryC.3ox@netcom.com>
  6. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  7. References: <4gkvhk$b1v@nms.telepost.no> <4gmpbs$cvl@news1.usa.pipeline.com>
  8. Date: Sun, 25 Feb 1996 09:34:59 GMT
  9. Sender: marnold@netcom20.netcom.com
  10.  
  11. grantp@usa.pipeline.com(Pete) writes:
  12.  
  13. >On Feb 23, 1996 18:03:31 in article <Re: DLL's with classes in them>,
  14. >'Carsten Arnholm <ca@sesam.dnv.no>' wrote: 
  15. >>J P Crocker <whl.adv.eng@dial.pipex.com> wrote: 
  16. >>>Here's one... 
  17. >>> 
  18. >>>I'm using Borland Turbo C++ 3.1, and am trying to create a DLL with a
  19. >class  
  20. >>>definition which I can import into my App.  I've decared the class in the
  21. >DLL  
  22. >> 
  23. >> .. [ sample deleted ] .. 
  24. >> 
  25. >>Unfortunately, I do not believe this is possible. DLL's support only
  26. >C-style 
  27. >>API functions. You can have objects inside & outside the DLL, but you
  28. >cannot 
  29. >>import or export such objects. 
  30. >> 
  31. >>If someone can prove me wrong, I would be most grateful. 
  32. >> 
  33. >Ok, I'll take the bait :-).  Two commercial examples of class libraries 
  34. >implemented as DLL's: 
  35. >     MFCxx.DLL 
  36. >     OWLxx.DLL 
  37.  
  38. That's right, the orignal poster is wrong.  Both Borland and Microsoft
  39. (and I'm sure others) offer way to export whole C++ classes from DLLs.
  40. Unfortunately (aside from just the name-"mangling/decorating" issues
  41. which usually foul-up cross-compiler C++ linking), each vendor's versions 
  42. of exported classes is usually not compatible with the others' (either
  43. because of the name mismatches or because of the techniques used to
  44. export classes).
  45.  
  46. So, it is definitely possible to use an object whose (C++) code resides 
  47. in a DLL (I've done it!).  But, if you choose to use this approach, be 
  48. sure that everyone who will use your DLLs has the same brand of C++ 
  49. compiler you do.  If you want your DLL to be the most compatible, stick 
  50. with normal C-style exported functions. 
  51.  
  52. Keep in mind that there *is* a cross-compiler, totally compatible way to 
  53. export objects from DLLs (and even applications).  It's called OLE 2.0.
  54.  
  55. Regards,
  56. -------------------------------------------------------------------------
  57. Matt Arnold                       |        | ||| | |||| |  | | || ||
  58. marnold@netcom.com                |        | ||| | |||| |  | | || ||
  59. Boston, MA                        |      0 | ||| | |||| |  | | || ||
  60. 617.389.7384 (h) 617.576.2760 (w) |        | ||| | |||| |  | | || ||
  61. C++, MIDI, Win32/95 developer     |        | ||| 4 3 1   0 8 3 || ||
  62. -------------------------------------------------------------------------
  63.